package com.hongsen.cn.presenter;

import com.hongsen.cn.Utils.GsonUtils;
import com.hongsen.cn.Utils.RxBus;
import com.hongsen.cn.application.DayAndMonthApplication;
import com.hongsen.cn.base.BaseModel;
import com.hongsen.cn.base.BaseObserver;
import com.hongsen.cn.base.BasePresenter;
import com.hongsen.cn.bean.BaseTitleBean;
import com.hongsen.cn.bean.OrderBean;
import com.hongsen.cn.bean.PoliceBean;
import com.hongsen.cn.bean.RxValue;
import com.hongsen.cn.bean.TheKeyPersonelBean;
import com.hongsen.cn.contract.PoliceDescView;

import java.util.List;

import static com.hongsen.cn.bean.RxBusEventKey.FINISH_UNCLICK_ACTIVITY;

public class PoliceDescPresenter extends BasePresenter<PoliceDescView> {

    public PoliceDescPresenter(PoliceDescView baseView) {
        super(baseView);
    }

    /**
     * 今日违规
     */
    public void getPhotoStrs(final String mjbh) {
        addDisposable(restApi.getPhotoeStrs(mjbh), new BaseObserver(baseView) {
            @Override
            public void onSuccess(Object o) {
                BaseModel<String> model = (BaseModel<String>) o;
                baseView.getPhotoStr(model.getData());
            }

            @Override
            public void onError(String msg) {
                //baseView.showError(msg);
            }
        });
    }

    /**
     * 角色预约
     */
    public void getOrderList(final String type, final String bodyId, final String policeId) {
        addDisposable(restApi.getOrderList(type, bodyId, policeId), new BaseObserver(baseView) {
            @Override
            public void onSuccess(Object o) {
                BaseModel<List<OrderBean>> model = (BaseModel<List<OrderBean>>) o;
                baseView.getOrderList(type, bodyId, model.getData());
                DayAndMonthApplication.getInstance().logger.debug(">>>getUndisposedInfo违规人员:" + GsonUtils.getInstance().toJson(model));
            }

            @Override
            public void onError(String msg) {
                DayAndMonthApplication.getInstance().logger.debug(">>>getUndisposedInfo违规人员获取失败:" + msg);
            }
        });
    }

    /**
     * 今日违规、加戴械具、动态人员、出所人员数量
     */
    public void getTitleInfo() {
        addDisposable(restApi.getTopPersonalData(), new BaseObserver(baseView) {
            @Override
            public void onSuccess(Object o) {
                BaseModel<BaseTitleBean> model = (BaseModel<BaseTitleBean>) o;
                baseView.getTitleInfo(model.getData());
            }

            @Override
            public void onError(String msg) {
                //baseView.showError(msg);
            }
        });
    }

    /**
     * 民警人脸抓拍登录
     * 12396300
     */
    public void login(String policeId) {
        addDisposable(restApi.login(policeId), new BaseObserver(baseView) {
            @Override
            public void onSuccess(Object o) {
                BaseModel<PoliceBean> model = (BaseModel<PoliceBean>) o;
                baseView.getLogiInfo(model.getData());
                DayAndMonthApplication.getInstance().logger.debug(">>>ID登录成功login:" + GsonUtils.getInstance().toJson(model));

            }

            @Override
            public void onError(String msg) {
                //baseView.showError(msg);
                DayAndMonthApplication.getInstance().logger.debug(">>>ID登录失败login:" + msg);
            }
        });
    }
}
